-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: Support custom mobile Demo editor setup configuration #54957
build: Support custom mobile Demo editor setup configuration #54957
Conversation
Applying optional setup configuration files allows developers to modify the Demo editor environment via Hooks, e.g. to set custom `initialHtml` for the editor.
Size Change: +22.5 kB (+1%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
The `require.context` function is undefined in the test environment, as it is a Metro-specific capability. The most straightforward way to avoid test failures is to disable this code that relates to the local development workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊 ! Thanks @dcalhoun for investigating a workaround for the optional require
, and introducing this feature 🏅 !
Apart from running the testing instructions, I also checked that modifications to the setup-local.js
file are applied live when running the Metro server 🎊.
@@ -27,6 +27,7 @@ module.exports = { | |||
inlineRequires: false, | |||
}, | |||
} ), | |||
unstable_allowRequireContext: true, // Used for optional setup configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need to keep an eye on this unstable parameter when upgrading Metro (probably in the next React Native upgrade effort), in case it produces a failure in loading the local setup.
Contributors will likely never discover or benefit from this customization ability if it is not documented.
Flaky tests detected in 92725d2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6421741322
|
What?
Support custom mobile Demo editor setup configuration.
Why?
Applying optional setup configuration files allows developers to modify
the Demo editor environment via Hooks, e.g. to set custom
initialHtml
for the editor.
How?
Rely upon the experimental
unstable_allowRequireContext
Metro configuration toenable searching for the optional
setup-local.js
configuration file viarequire.context
.This approach is a workaround as loading the optional configuration file fails
when using
allowOptionalDependencies
, as outlined in facebook/metro#666 (comment).Testing Instructions
Without custom configuration
npm run native start:reset
.npm run native ios
ornpm run native android
.initial-html
configuration, displaying the expected blocks.
With custom configuration
Example setup configuration
packages/react-native-editor/src/setup-local.js
npm run native start:reset
.npm run native ios
ornpm run native android
.the blocks within the custom configuration.
Testing Instructions for Keyboard
n/a
Screenshots or screencast
n/a